<template>
  <draggable id="addForm" class="addalarmrecord" @start="onStart" @end="onEnd">
    <slot id="formTitle">
      <h3 style="text-align: center">Form Title</h3>
    </slot>
    <el-form ref="form" :model="form" label-width="80px" @submit.native.prevent>
      <el-form-item label="Name" style="width: 80%">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="Status">
        <el-select v-model="form.status" placeholder="Status" clearable>
          <el-option label="Open" value="Open"></el-option>
          <el-option label="Pending" value="Pending"></el-option>
          <el-option label="Closed" value="Closed"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="CreateTime">
        <el-col :span="11">
          <el-date-picker
            type="datetime"
            placeholder="Choose Time"
            v-model="form.gentime"
            style="width: 100%"
          ></el-date-picker>
        </el-col>
      </el-form-item>
      <el-form-item label="Owner" style="width: 300px">
        <el-input v-model="form.handleby"></el-input>
      </el-form-item>
      <el-form-item label="From">
        <el-radio-group v-model="form.resource">
          <el-radio label="DV"></el-radio>
          <el-radio label="I2000"></el-radio>
          <el-radio label="Others"></el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="Progress" style="width: 90%">
        <el-input type="textarea" v-model="form.progress"></el-input>
      </el-form-item>
      <el-form-item>
        <slot id="submit"><el-button>Form Confirm</el-button> </slot>
        <el-button @click="doClose">Cancel</el-button>
      </el-form-item>
    </el-form>
  </draggable>
</template>

<script>
import draggable from "vuedraggable";
export default {
  name: "alarmForm",
  props: {
    dialog_visible: Boolean,
  },
  components: { draggable },
  data() {
    return {
      visible: this.dialog_visible,
      form: {
        name: "",
        status: "Open",
        gentime: this.$store.getters.nowTime,
        progress: "",
        handleby: "xxx",
        resource: "DV",
      },
    };
  },
  watch: {
    visible(val) {
      this.dialog_visible = val;
    },
  },
  computed: {},
  methods: {
    onStart() {
      this.drag = true;
    },
    onEnd() {
      this.drag = false;
    },
    doClose() {
      this.$emit("dialogVisibleEvent", false);
    },
  },
  created() {},
};
</script>

<style scoped>
.addalarmrecord {
  margin: 10px;
  border: red 1px solid;
  width: 800px;
  background-color: #f1f5f5;
  position: absolute;
  top: 135px;
  left: 288px;
}
</style>